package com.liht.nfc

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.ViewGroup
import android.widget.TextView
import com.liht.nfc.simple1.SimpleNfcActivity
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initList()
    }

    val map = mapOf(
            "SimpleNfcActivity" to SimpleNfcActivity::class.java,
    )

    fun initList(){
        map.entries.forEach {
            TextView(this).apply {
                this.layoutParams = ViewGroup.LayoutParams(
                        ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT
                )
                this.setPadding(10,20,10,20)
                this.text = it.key
                this.setOnClickListener { v->
                    startActivity(Intent(this@MainActivity,it.value))
                }
                list.addView(this)
            }
        }
    }

}